package com.example.mobile2021606129ly0615;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class MySQLiteOpenHelper extends SQLiteOpenHelper {
    public MySQLiteOpenHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql="create table user(_id student primary key autoincrement , name Text not null,age integer,score float)";
                db.execSQL(sql);

        ContentValues contentValues = new ContentValues();
        contentValues.put("name","one");
        contentValues.put("age","18");
        contentValues.put("score","100.0");
        db.insert("user",null,contentValues);

        contentValues.put("name","two");
        contentValues.put("age","19");
        contentValues.put("score","90.0");
        db.insert("user",null,contentValues);

        contentValues.put("name","three");
        contentValues.put("age","20");
        contentValues.put("score","80.0");
        db.insert("user",null,contentValues);

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
